<template>
    <div>
        <div>
            <H1>欢迎注册</H1>
        </div>
        <div>
            <div>
            用户名：<input type="text" v-model="formData.username" />
            </div>
             <div>
            密码<input type="password" v-model="formData.userpass"  />
            </div>
             <div>
            密码确认：<input type="password" v-model="formData.reuserpass"  />
            </div>
            <div>
            邮箱：<input type="email" v-model="formData.user_email" />
            </div>
            <div>
                <button @click="regUser">注册新账号</button>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    name:'RegisterView',
    data(){
        return{
            formData:{
                username:"",
                userpass:"",
                reuserpass:"",
                user_email:""
            }
        }
    },
    methods:{
        async regUser(){
            let res = await this.$http.post("regUser",this.formData);
            if(res.state==200){
                alert("注册成功");
                // location.href='login'   //js原生方法
                this.$router.push("/login");
            }else{
                alert(res.msg);
            }
        }
    }
}
</script>